/**
 * Created by Administrator on 2015/5/19 0019.
 */
define('nav',function(){
    return nav=avalon.define({
        $id:"nav",
        inSide:false,
        ready:function(){
            nav.reset()
        },
        reset:function(){
            nav.now=0
        },
        //导航项目高亮
        now:0 , //导航条选中项的索引
        Active: function (index) {
            nav.now=index;
        },
        /* 用户数据 */
        user:{
            UserName:"",
            uid:""
        },
//        登出
        logout:function(){
            $.call({
                type:"post",
                i:6,
                success:function(data){
                    if(data.c==200){
                        nav.inSide=false
                        tip.on("已退出登录",1,3000)
                        cache.go({
                            "tsy": "",
                            "un": "",
                            "uid": "",
                            "HURL":""
                        })
                        window.location.reload()
                    }
                }
            })
        },

        stbIn:function(){
            door.comeIn(openAccessDoing);
//        layout.url="./body/home.html"
            //加载所依赖的VM
            require(['stb'], function () {
                stb.ready()
                //执行VM加载成功之后执行的页面变化
                modal.url="./plugins/stb/stb.html";
                modal.getIn()
                avalon.scan()
            })
        },

        //搜索文章
        keyWords:"",
        search:function(){
            list.search(nav.keyWords)
        },

        //  跳转到后台管理
        toAdmin:function  () {
           tip.on("123");
            //能通过的后台管理员组
            var admins=[109,2,3];
            var uid=cache.go('uid');
//            tip.on(uid);
            for ( var i=0 ;i<admins.length ; i++) {
                if(uid == admins[i] ) {
                    tip.on("zhaodao",0);
                    window.location.href="./admin.html#!/";
                }
            }
        }

    })
})
